﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using IHISCETeim.BLL;
using IHISCETeim.Library;
using IHISCETeim.Model;
using System.Data;
using System.Text;

namespace IHISCETeim.Web.MachineSys.MarketModel
{
    public partial class MBaoYangAdd : PageBase
    {
        protected override string DWZRef
        {
            get
            {
                return "MBaoYangListEasyUI";
            }
        }

        protected override Permission[] PowerKey
        {
            get
            {
                return new Permission[] { Permission.新增 };
            }
        }


        protected void Page_Load(object sender, EventArgs e)
        {
            if (GetRequestValue<string>("ajaxmethod", "") == "add")
            {
                addmenu();

            }
        }
        private void addmenu()
        {
            MBaoYangInfo obj = Request.SerializableObject<MBaoYangInfo>();

            MBaoYangInfo objChk= MBaoYangController.GetByJH(obj.JH);
            if (objChk != null)
            {
                ErrorJson("机号"+objChk.JH+" 已存在，请检查再添加。");
                return;
            }

            if (obj.ZSYY == "展会政策")
            {
                obj.BB_ZHHTH = obj.ZH_RQ + " " + obj.ZH_DD;
            }
            else
            {
                obj.BB_ZHHTH = obj.QT_XSHTH;
            }
            //判断是否已存在,已申请过

            int id = MBaoYangController.Add(obj);
            if (id > 0)
            {
                SuccessJson("成功添加");
            }
            else
            {

                ErrorJson("添加失败");
            }

        }
    }
}